package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
)


func main() {

	router := gin.Default()
	router.Delims("<{", "}>")
	router.LoadHTMLFiles("./html/index.html")
	//router.Static("/html", "js")
	router.StaticFS("/html", http.Dir("./html"))
	router.GET("/", func(c *gin.Context) {
		c.HTML(http.StatusOK, "index.html", map[string]interface{}{})
	})
	router.POST("/check", func(c *gin.Context) {
		sql,_ := c.GetPostForm("sql")
		resList := NewAnalysisMysql(sql).Analysis()
		if resList == nil {
			resList = append(resList, "审核通过")
		}
		res := map[string]interface{}{"code":200, "data":resList,"msg":"成功"}
		//str, _ := json.Marshal(res)
		c.JSON(http.StatusOK, res)
	})
	_ = router.Run(":8080")
}

func test() {
	sql := "CREATE TABLE `vd_resouce_library_activity_poster` (" +
		"`id` INT ( 11 ) NOT NULL AUTO_INCREMENT COMMENT 'ID',`order` VARCHAR ( 70 ) NOT NULL COMMENT '关联账号',`create_account_id` INT ( 11 ) NOT NULL COMMENT '创建者'," +
		"PRIMARY KEY ( `id` ) USING BTREE " +
		") ENGINE =   222     AUTO_INCREMENT = 33 DEFAULT CHARSET = utf8 ROW_FORMAT = COMPACT COMMENT = '789';"

	o := NewAnalysis(sql).Analysis()

	NewAnalysisMysql(sql)
	fmt.Println(o)
}
